<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>接种记录</title>
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
</head>

<body>
    <table id="jiezhong" lay-filter="test">

    </table>
    <script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../lib/jquery-3.4.1/jQuery.js"></script>
    <script>

        //通过定义为方法将参数(数据)传递给表格,并为表格动态添加数据
        function UserTable(list) {
            layui.use('table', function () {

                var table = layui.table;

                table.render({
                    elem: '#jiezhong'
                    //使用layui数据表格的data属性将Ajax调用的后台数据绑定
                    , data: list,
                    parseDate:function (res){
                        console.log("parseDate")
                        console.log(res);
                        return {
                            "code":res.status,
                            "msg":res.message,
                            "count":res.total,
                            "data":res.data
                        }
                    },
                    response: {
                        statusName: 'status' //规定数据状态的字段名称，默认：code
                        ,statusCode: 200 //规定成功的状态码，默认：0
                        ,msgName: 'msg' //规定状态信息的字段名称，默认：msg
                        ,countName: 'count' //规定数据总数的字段名称，默认：count
                        ,dataName: 'data' //规定数据列表的字段名称，默认：data
                    },
                    cols: [[
                        { field: 'uid', title: '接种用户id', width: '120' },
                        { field: 'did', title: '接种疫苗id', width: '120' },
                        { field: 'time', title: '接种时间', width: '200' },
                        { field: 'dose', title: '接种剂次', width: '120' },
                        { field: 'vacc_unit', title: '接种单位', width: '200' },
                        { field: 'enterprise', title: '生产企业', width: '120' },
                        { field: 'batch_number', title: '疫苗批号', width: '120' },
                    ]]
                })
            })
        }

        var storage = window.localStorage;
        var number=storage.getItem("number");
        console.log(number);
        var obj = {
            "number":parseInt(number)
        }
        console.log(JSON.stringify(obj));
        $.ajax({
            type: "POST",
            contentType: 'application/json',
            url: "http://110.42.199.36:8081/vaccination/getVacMsgByNumber",
            data:JSON.stringify(obj),
            dataType: 'json',
            success: function (data) {
                console.log("成功");
                console.log(data);
                console.log(data.data);
                if(data.data != null){
                    UserTable(data.data);
                }

            }
        })
    </script>
</body>

</html>